public class Commodity {
    private String name;
    private int price;
    private int reserve;
    private static int count = 0;
    private char idChar = 'A';
    private boolean canPurchase;

    public Commodity(String name, int price, int reserve) {
        this.setIdChar((char) (idChar + count));
        this.name = name;
        this.price = price;
        this.reserve = reserve;
        count++;
    }

    public String isCanPurchase() {
        if (reserve == 0) {
            return "X";
        }
        if (canPurchase) {
            return "O";
        } else
            return " ";
    }

    public void setCanPurchase(boolean canPurchase) {
        this.canPurchase = canPurchase;
    }

    public char getIdChar() {
        return idChar;
    }

    public void setIdChar(char idChar) {
        this.idChar = idChar;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPrice() {
        return price;
    }

    public void setPrice(int price) {
        this.price = price;
    }

    public int getReserve() {
        return reserve;
    }

    public void setReserve(int reserve) {
        this.reserve = reserve;
    }

    @Override
    public String toString() {
        return "Commodity{" +
                "name='" + name + '\'' +
                ", price=" + price +
                ", reserve=" + reserve +
                ", idChar=" + idChar +
                '}';
    }
}
